package xiegd.study.map;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @Author: xieguangda
 * @Description:
 * @Date: 2023/10/8 10:24
 */
public class HasTest {
    // // 检查key是否已经存在
    //List<String> values = transferSeparatedMessageMap.getOrDefault(key, new ArrayList<>());
    //
    public static void main(String[] args) {
        Map<Long, List<String>> transferSeparatedMessageMap = new HashMap<>();
        Long e = 111L;
        String name = "test";
//        transferSeparatedMessageMap.put(e, Arrays.stream(new String[]{"我不是空的"})
//                .collect(Collectors.toList()));
        List<String> separatedEmpList = transferSeparatedMessageMap.get(e);
        if(separatedEmpList != null){
            System.out.println("我不是空的");
            separatedEmpList.add(name);
        } else{
//            System.out.println("我是空的");
//            transferSeparatedMessageMap.put(e, Arrays.stream(new String[]{"我是空的"})
//                    .collect(Collectors.toList()));
        }

        List<String> values = transferSeparatedMessageMap.getOrDefault(e, new ArrayList<>());
        values.add("我是后面加的呢");
        System.out.println("test::" + values);
    }

    @Test
    public void test(){
        List<String> list = Stream.of("a", "b", "c").collect(Collectors.toList());
        Arrays.stream(new String[]{"33","444"}).collect(Collectors.toList());
       // Arrays.stream("33","444").collect(Collectors.toList());
        list.add("ddd");

        System.out.println(list);

        //List<String> list2 = List.of("a", "b", "c");

    }

    @Test
    public void listHashMap(){
        LinkedHashMap<String, Integer> linkedHashMap = new LinkedHashMap<>();
        linkedHashMap.put("Four", 4);
        linkedHashMap.put("Five", 5);
        linkedHashMap.put("One", 1);
        linkedHashMap.put("Two", 2);
        linkedHashMap.put("Three", 3);

        for (Map.Entry<String, Integer> entry : linkedHashMap.entrySet()) {
            System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());
        }
    }

    @Test
    public void maptet(){
        Boolean flag = true;
        //System.out.println(flag == false);

        System.out.println(Boolean.FALSE.equals(flag));;
    }
}
